import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pplive/common/utils.dart';

import '../icon_model.dart';
import '../user.dart';

extension UserExtension on User {
  Widget createRichText() {
    List<InlineSpan> viewsWithSpacing = [];
    listLabel.asMap().forEach((index, e) {
      viewsWithSpacing.add(e.createRichText());
      if (index < listLabel.length - 1) {
        viewsWithSpacing.add(TextSpan(
          text: ' ', // 这里可以根据需要调整间距的大小
          style: TextStyle(color: Colors.black),
        ));
      }
    });

    return Container(
      child: RichText(
        text: TextSpan(children: viewsWithSpacing),
      ),
    );
  }
}

extension IconModelExtension on IconModel {
  WidgetSpan createRichText() {
    return WidgetSpan(
      child: Image.network(
        width: width / 2,
        height: height / 2,
        iconUrl, // 替换为你的图片URL
      ),
    );
  }
}
